﻿using AspectCore.DynamicProxy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AopDemo
{
    public class CustomInterceptorAttribute : AbstractInterceptorAttribute
    {
        public async override Task Invoke(AspectContext context, AspectDelegate next)
        {
            try
            {
                Common.LogHelper.Info("方法执行之前");
                await next(context);
            }
            catch (Exception)
            {
                Common.LogHelper.Error($"执行{context.Implementation.GetType()}.{context.ProxyMethod.Name}方法出错!");
                throw;
            }
            finally
            {
                Common.LogHelper.Info("方法执行之后");
            }
        }

    }
}
